package com.cc.springbootvalidatedemo.controller;

import com.cc.springbootvalidatedemo.domain.CreateGroup;
import com.cc.springbootvalidatedemo.domain.User;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
//@Validated // 必须加在类上
public class UserController {

    @PostMapping("/create")
    public String create(@Validated(CreateGroup.class) @RequestBody User user) {
        // 仅校验CreateGroup规则
        return "success";
    }
}
